package day06;

import java.util.Arrays;
import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {

        double[] scores = inputScore(6);
        double avg = calAvg(scores);
        System.out.println("平均分为：" + avg);

    }

    //录入n位评委评分
    public static double[] inputScore(int n) {
        double[] score = new double[n];
        Scanner sc = new Scanner(System.in);
//        System.out.println("请输入评委的评分：");
        for (int i = 0; i < n; i++) {
            System.out.println("请输入第" + (i + 1) + "评委的评分：");
            score[i] = sc.nextInt();
        }
        return score;

    }

    //计算平均分
    public static double calAvg(double[] arr) {
        Arrays.sort(arr);
//        System.out.println(Arrays.toString(arr));
//        double brr[] = Arrays.copyOf(arr, arr.length);
        double sum = 0;
        double avg;
        for (int i = 1; i < arr.length - 1; i++) {
            sum += arr[i];
        }
//        System.out.println(sum);
        avg = sum / (arr.length - 2);
        return avg;
    }

}
